<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <input type="text" placeholder="请输入1-100之间的整数" id="i1">
    <input type="button" value="猜一猜" onclick="f()">
    <div id="d1">结果:猜一猜!</div>
</body>
<script>
    /* 随机产生1-100整数 */
    let x = parseInt(Math.random() * 100) + 1;
    let count = 0;
    function f() {
        count++;
        if (i1.value > x) {
            d1.innerText = "结果:猜大了!";
        } else if (i1.value < x) {
            d1.innerText = "结果:猜小了!";
        } else {
            d1.innerText = "结果:恭喜你第"+count+"次猜对了";
        }
    }
</script>
</html>